import {BasicColumn, FormSchema} from '@/components/Table';
import {h} from 'vue';
import {Tag} from 'ant-design-vue';

type CheckedType = boolean | string | number;
export const columns: BasicColumn[] = [
  {
    title: '账号',
    dataIndex: 'userName',
  },
  {
    title: '角色',
    dataIndex: 'role',
    width: 180,
    customRender: ({ record }) => {
      const role = record.role;
      let value="";
      switch (role) {
        case "manage":
          value="管理员";
          break;
        case "store":
          value="仓储人员";
          break;
      }
      return h(Tag, {

      },value);
    },
  },
  {
    title: '昵称',
    dataIndex: 'nickName',
    width: 150,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'keyword',
    label: '账号',
    component: 'Input',
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'userName',
    label: '账号',
    required: true,
    component: 'Input',
  },
  {
    label: '昵称',
    field: 'nickName',
    required: false,
    component: 'Input',
  },
  {
    label: '角色',
    field: 'role',
    component: 'Select',
    required: true,
    componentProps: {
      options: [
        { label: '管理员', value: "manage" },
        { label: '仓储人员', value: "store" }

      ],
    },
  },
  {
    label: '密码',
    field: 'passWord',
    required: false,
    ifShow:true,
    component: 'Input',
  },

];
